import 'package:flutter/material.dart';

import '../tabs/tabs.dart';
import '../pages/login.dart';
import '../pages/register.dart';
// import '../tabs/Search2.dart';
// import '../tabs/Search3.dart';
// import '../page/AppBarDemo.dart';
// import '../page/AppBarControllerPage.dart';
// import '../form/TextFiled.dart';
// import '../form/CheckedBox.dart';
// import '../form/RadioPage.dart';
// import '../date/DatePicker.dart';

// 配置路由
final routes = {
  '/': (context) => Tabs(),
  '/login': (context) => Login(),
  '/register': (context) => Register(),
  // '/search2': (context, {arguments}) => Seacrch2(arguments: arguments),
};

// 固定写法
// ignore: top_level_function_literal_block
final onGenerateRoute = (RouteSettings settings) {
  // 路由统一处理
  final String? name = settings.name;
  final Function? pageContentBuilder = routes[name];
  if (pageContentBuilder != null) {
    print(settings.arguments);
    if (settings.arguments != null) {
      final Route route = MaterialPageRoute(
          builder: (context) =>
              pageContentBuilder(context, arguments: settings.arguments));
      return route;
    } else {
      final Route route =
          MaterialPageRoute(builder: (context) => pageContentBuilder(context));
      return route;
    }
  }
};
